home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 159 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: tribeca.ios.com!aldo
  2. From: aldo@tribeca.ios.com (Aldo Di Domenico)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: These string questions just won't go away......
  5. Date: 2 Jan 1996 23:16:36 GMT
  6. Organization: Internet Online Services
  7. Message-ID: <4cceck$6cp@news2.ios.com>
  8. References: <4c67g1$k88@news1.usa.pipeline.com>
  9. NNTP-Posting-Host: tribeca.ios.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. On 31 Dec 1995 14:42:09 GMT, Pete (grantp@usa.pipeline.com) wrote:
  13. :  
  14. : >int 
  15. : >main(void) 
  16. : >{ 
  17. : >char string[] = "Strawberry Fields forever"; 
  18. : >f(&string[10]); 
  19. : >return 0; 
  20. : >} 
  21. : > 
  22. : >void 
  23. : >f(char *input) 
  24. : >{ 
  25. : >input--; 
  26. : >printf(*input); 
  27. :  
  28. : This should cause a fault.  What you probably want to do is omit 
  29. : the dereference and use printf(input).  Then it should print the 
  30. : remainder of the string beginning with the 10th character. 
  31. : >return; 
  32. <other stuff snipped>
  33.  
  34. OK, OK, I'm sorry.  I wrote this post too hastily.  What I meant to write 
  35. was:
  36.  
  37. printf("%c", *input);     /* I hope I got it right this time.  :) */
  38.  
  39. Now, my question (which has since been answered) was about whether 
  40. function f() would be able to "find" string[9], since f() was called with 
  41. a pointer to string[10], and I was not sure if the program could back up 
  42. like that.  Anyway, I didn't mean to cause so much confusion with my 
  43. sloppiness.  Thanks again.
  44.  
  45.  
  46.                                             Aldo DiDomenico
  47.  
  48. "I smell a rat in Philadelphia" --Patrick Henry, explaining his boycott
  49.                                   of The Constitutional Convention of 1787
  50.  
  51. email: aldo@tribeca.ios.com    |  Visit my page for instructions on how to
  52. www:   http://tribeca.ios.com  |  set up your link there.
  53. finger for PGP public key      |
  54.  
  55.